package com.example.service;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.entity.File;
import com.example.entity.UserAction;
import com.example.mapper.FileMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-05-31
 */
@Service
public class FileService extends ServiceImpl<FileMapper, File> implements IService<File> {
    @Resource
    private FileMapper fileMapper;

    public File getbyFilename(String name) {
        File one = getOne((Wrappers.<File>lambdaQuery().eq(File::getFilename,name)));
        return one;
    }
    public List<File> getlist1() {
        List<File> lists = fileMapper.getlist1();
        return lists;
    }
    public List<File> getlist2() {
        List<File> lists = fileMapper.getlist2();
        return lists;
    }
    public void  update1(String filename,String path) {
//        String path="https://x12ie.oss-cn-beijing.aliyuncs.com/fire/"+filename;
              String uploadtime=DateUtil.formatDateTime(new Date());
              int  downloadcount=0;
              int  collectcount=0;

           fileMapper.update1(filename,path,uploadtime,downloadcount, collectcount);
    }
}
